//
//  EnterAccountView.m
//  MUBATE
//
//  Created by sunbin on 2017/2/15.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "EnterAccountView.h"

@interface EnterAccountView()

@property (weak, nonatomic) IBOutlet UILabel *findType;
@property (weak, nonatomic) IBOutlet UILabel *findPwd;
@property (weak, nonatomic) IBOutlet UILabel *linebottomText;

@end

@implementation EnterAccountView
- (void)awakeFromNib{
    [super awakeFromNib];

    // 设置label标题
    [NHUtils setLabel:_findType text:NSLocalizedString(@"Fill in the account", @"Fill in the account") textColor:[UIColor alertTextColor] font:Launch_welcomeFon];
    [NHUtils setLabel:_findPwd text:NSLocalizedString(@"Retrieve password", @"Retrieve password") textColor:[UIColor alertTextColor] font:Launch_comeBackFon];
    [NHUtils setLabel:_linebottomText text:NSLocalizedString(@"We will send the verification code to you to fill in the account", @"We will send the verification code to you to fill in the account") textColor:[UIColor alertTextColor] font:Launch_linebottomTextFon];

    
    
    // 文本输入框
    [_account setPlaceholder:NSLocalizedString(@"Please confirm your account",@"Please confirm your account")];
    [_account setPlaceholderColor:[UIColor PlaceholderColor]];
    [_account setTextColor:[UIColor bodyTextColor]];
    // 按钮
    [NHUtils setButton:_confirmBtn isLaunch:YES setTitle:NSLocalizedString(@"next step", @"next step") setLayerCornerRadius:0 setFont:Launch_confirmBtnFon];
    _confirmBtn.enabled = NO;
}


+ (instancetype)LoadEnterAccountView{
    EnterAccountView *enterAccount = [self loadFromNib];

    return enterAccount;
}

+ (instancetype)loadFromNib{
    
    NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"EnterAccountView" owner:nil options:nil];
    return [objects lastObject];
}

- (IBAction)editingChanged:(UITextField *)sender {
    _confirmBtn.enabled = ![NHUtils isBlankString:_account.text];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    if (![NHUtils isBlankString:_account.text]) {
        [self nextStep:_confirmBtn];
    }
    return YES;
}
- (IBAction)nextStep:(UIButton *)sender {
    NSInteger index = sender.tag - 5;
    if (self.nextStepHandler) {
        self.nextStepHandler(_account.text ,index);
    }
}


@end
